package com.sky.controller.user;

import com.sky.pojo.Setmeal;
import com.sky.result.Result;
import com.sky.service.user.UserSetmealService;
import com.sky.vo.DishItemVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user/setmeal")
@Slf4j
@Api(tags = "c端-套餐相关接口")
@RequiredArgsConstructor
public class UserSetmealController {
    private final UserSetmealService userSetmealService;

    @GetMapping("/list")
    @ApiOperation("根据分类id查询套餐")
    public Result<List<Setmeal>> findListByCategoryId(Long categoryId){
        List<Setmeal> list = userSetmealService.findListByCategoryId(categoryId);
        return Result.success(list);
    }

    @GetMapping("/dish/{setmealId}")
    @ApiOperation("根据套餐id查询包含的菜品")
    public Result<List<DishItemVO>> findDishBySetmealId(@PathVariable Long setmealId){
        List<DishItemVO> list = userSetmealService.findDishBySetmealId(setmealId);
        return Result.success(list);
    }
}
